package com.example.service;

import com.example.entity.HistoryEvents;
import com.example.entity.HistoryThings;
import com.example.mapper.HistoryEventsMapper;
import com.example.mapper.HistoryThingsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
历史事件业务处理
 */
@Service
public class HistoryEventsService {

    @Resource
    private HistoryEventsMapper historyEventsMapper;

    public void add(HistoryEvents historyEvents) {
        historyEventsMapper.insert(historyEvents);
    }

    public void deleteById(Integer id) {
        historyEventsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(HistoryEvents historyEvents) {
        historyEventsMapper.updateById(historyEvents);
    }

    public HistoryEvents selectById(Integer id) {
        return historyEventsMapper.selectById(id);
    }

    public List<HistoryEvents> selectAll(HistoryEvents historyEvents) {
        return historyEventsMapper.selectAll(historyEvents);
    }

    public PageInfo<HistoryEvents> selectPage(HistoryEvents historyEvents, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<HistoryEvents> historyEventsList = historyEventsMapper.selectAll(historyEvents);
        return PageInfo.of(historyEventsList);
    }
}
